/*
 *    Copyright (c) 2018-2025, proj All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the proj developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: proj
 */

package com.ykht.proj.coupon.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ykht.proj.common.core.exception.BusinessException;
import com.ykht.proj.common.core.util.R;
import com.ykht.proj.common.log.annotation.SysLog;
import com.ykht.proj.common.security.util.SecurityUtils;
import com.ykht.proj.coupon.entity.FxBrandMoneyFlow;
import com.ykht.proj.coupon.service.FxBrandMoneyFlowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;


/**
 * 品牌账户资金流水
 *
 * @author proj code generator
 * @date 2021-08-18 18:18:54
 */
@RestController
@AllArgsConstructor
@RequestMapping("/fxbrandmoneyflow" )
@Api(value = "fxbrandmoneyflow", tags = "品牌账户资金流水管理")
public class FxBrandMoneyFlowController {

    private final  FxBrandMoneyFlowService fxBrandMoneyFlowService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param fxBrandMoneyFlow 品牌账户资金流水
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('coupon_fxbrandmoneyflow_view')" )
    public R getFxBrandMoneyFlowPage(Page page, FxBrandMoneyFlow fxBrandMoneyFlow) {
        return R.ok(fxBrandMoneyFlowService.page(page, Wrappers.query(fxBrandMoneyFlow)));
    }


    /**
     * 通过id查询品牌账户资金流水
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('coupon_fxbrandmoneyflow_view')" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(fxBrandMoneyFlowService.getById(id));
    }

    /**
     * 新增品牌账户资金流水
     * @param fxBrandMoneyFlow 品牌账户资金流水
     * @return R
     */
    @ApiOperation(value = "品牌充值")
    @PostMapping
//    @PreAuthorize("@pms.hasPermission('coupon_fxbrandmoneyflow_add')" )
    public R save(@RequestBody FxBrandMoneyFlow fxBrandMoneyFlow) {
		fxBrandMoneyFlowService.Recharge(fxBrandMoneyFlow);
        return R.ok();
    }

    /**
     * 修改品牌账户资金流水
     * @param fxBrandMoneyFlow 品牌账户资金流水
     * @return R
     */
    @ApiOperation(value = "修改品牌账户资金流水", notes = "修改品牌账户资金流水")
    @SysLog("修改品牌账户资金流水" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('coupon_fxbrandmoneyflow_edit')" )
    public R updateById(@RequestBody FxBrandMoneyFlow fxBrandMoneyFlow) {
        return R.ok(fxBrandMoneyFlowService.updateById(fxBrandMoneyFlow));
    }

    /**
     * 通过id删除品牌账户资金流水
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除品牌账户资金流水", notes = "通过id删除品牌账户资金流水")
    @SysLog("通过id删除品牌账户资金流水" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('coupon_fxbrandmoneyflow_del')" )
    public R removeById(@PathVariable Long id) {
        return R.ok(fxBrandMoneyFlowService.removeById(id));
    }

}
